package com.cssl.controller;


import com.cssl.domain.DtsGoods;
import com.cssl.domain.dto.DtsBrandDto;
import com.cssl.domain.dto.GoodsDto;
import com.cssl.domain.dto.GoodsSearchDto;
import com.cssl.domain.dto.PageDto;
import com.cssl.openFeign.GoodsFeignClient;
import com.cssl.util.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/goods")
@Api(value = "商品接口", tags = "商品相关操作")
public class GoodsController {
    @Autowired
    private GoodsFeignClient goodsFeignClient;

    @PostMapping("/firstPageGoods")
    @ApiOperation("展示首页商品(老)")
    public Result showFirstPageGoods(@RequestBody com.cssl.domain.Page page) {
        return goodsFeignClient.showFirstPageGoods(page);
    }

    /**
     * (根据浏览量和销售量判断)
     *
     * @return
     */
    @PostMapping("/prodList")
    @ApiOperation("展示热门商品2条")
    public Result getTwoHotGoods() {
        return goodsFeignClient.getTwoHotGoods();
    }

    /**
     * 获取商品列表
     *
     * @param goodsDto 查询条件
     * @return
     */
    @PostMapping("/goodsList")
    @ApiOperation("获得商品集合")
    public Result getGoodsList(@RequestBody GoodsDto goodsDto) {
        return goodsFeignClient.getGoodsList(goodsDto);
    }

    /**
     * 获得商品总数
     *
     * @return 商品总数数字
     */
    @PostMapping("/goodsCount")
    @ApiOperation("获得商品总数")
    public Result getTotalGoodsCount() {
        return goodsFeignClient.getTotalGoodsCount();
    }

    /**
     * 轮播图
     */
    @PostMapping("/indexImgs")
    @ApiOperation("轮播图")
    public Result getCarouselImage() {
        return goodsFeignClient.getCarouselImage();
    }

    /**
     * 公告列表
     *
     * @return
     */
    @PostMapping("/topNotice")
    @ApiOperation("公告列表")
    public Result topNoticeList() {
        return goodsFeignClient.topNoticeList();
    }

    /**
     * @return 成功返回 hotGoods , newGoods ,carouseImage,noticeList,allInfo,allGroup,allBrand , dtsCategories
     */
    @PostMapping("/firstPageInfo")
    @ApiOperation("首页数据")
    public Result getFirstPage() {
        return goodsFeignClient.getFirstPage();
    }

    /**
     * 公告
     *
     * @return
     */
    @PostMapping("/notice")
    @ApiOperation("公告")
    public Result getNotice(@RequestBody Map map) {
        return goodsFeignClient.getNotice(map);
    }

    /**
     * 查询三级商品分类
     *
     * @param map categoryId page size
     * @return totalPages ,  goodsList
     */
    @PostMapping("/getLevel3")
    @ApiOperation(value = "三级商品查询", notes = "二级id,page,size")
    public Result getLevel3(@RequestBody Map<String, Object> map) {
        return goodsFeignClient.getLevel3(map);
    }

    /**
     * 根据id获得商品所有的信息
     *
     * @param map id
     * @return
     */
    @PostMapping("/getGoodsInfoById")
    @ApiOperation(value = "根据id获得商品所有数据", notes = "商品id")
    public Result getGoodsInfoById(@RequestBody Map map) {
        return goodsFeignClient.getGoodsInfoById(map);
    }

    /**
     * 搜索关键字
     *
     * @return hotKeyWordList ,  goodsKeyWordList
     */
    @PostMapping("/searchHelp")
    @ApiOperation(value = "搜索帮助")
    public Result searchHelp() {
        return goodsFeignClient.searchHelp();
    }

    /**
     * 模糊搜索商品
     *
     * @param searchDto
     * @return goodsList ,  page ,categoryName
     */
    @PostMapping("/searchGoods")
    @ApiOperation(value = "模糊查询商品")
    public Result searchGoods(@RequestBody GoodsSearchDto searchDto) {
        return goodsFeignClient.searchGoods(searchDto);
    }

    /**
     * 具体商品的规格
     *
     * @param map 商品id goodsId
     * @return strings(默认选中的规格) ,  result全部规格
     */
    @PostMapping("/goodsSpecifications")
    @ApiOperation(value = "具体商品的规格", notes = "商品Id:goodsId")
    public Result goodsSpecifications(@RequestBody Map map) {
        return goodsFeignClient.goodsSpecifications(map);
    }

    @PostMapping("/getBrandById")
    @ApiOperation(value = "根据id获得品牌商", notes = "品牌商id")
    public Result getBrandById(@RequestBody Map map) {
        return goodsFeignClient.getBrandById(map);
    }

    @PostMapping("/getGoodsByBrandId")
    @ApiOperation(value = "根据品牌商id获得商品", notes = "DtsBrandDto")
    public Result getGoodsByBrandId(@RequestBody DtsBrandDto dto) {
        return goodsFeignClient.getGoodsByBrandId(dto);
    }

    @PostMapping("/getHotOrNewGoods")
    @ApiOperation(value = "获得热商品或最新商品", notes = "PageDto")
    public Result getHotAndNewGoods(@RequestBody PageDto dto) {
        return goodsFeignClient.getHotAndNewGoods(dto);
    }

    @PostMapping("/relevantData")
    @ApiOperation(value = "获取规格相对应的参数", notes = "商品id,选中的值")
    public Result relevantData(@RequestBody Map map) {
        return goodsFeignClient.relevantData(map);
    }

    @PostMapping("/getAllBrand")
    @ApiOperation(value = "分页品牌商", notes = "接收:page,size")
    public Result getAllBrand(@RequestBody Map map) {
        return goodsFeignClient.getAllBrand(map);
    }

    @PostMapping("/checkedSpecPrice")
    @ApiOperation(value = "选中规格的价格", notes = "id,规格")
    public Result checkedSpecPrice(@RequestBody Map map) {
        return goodsFeignClient.checkedSpecPrice(map);
    }

    @PostMapping("/goodsOnShelf")
    @ApiOperation(value = "上架新商品模块", notes = "商品基本信息，商品属性，商品规格，商品货品")
    public Result goodsOnShelf(@RequestBody Map map) {
        return goodsFeignClient.goodsOnShelf(map);
    }

    @PostMapping("/getGoodsRelated")
    @ApiOperation(value = "大家都在看商品", notes = "接收商品id")
    public Result getGoodsRelated(@RequestBody DtsGoods goods) {
        return goodsFeignClient.getGoodsRelated(goods);
    }

    @PostMapping("/getGoodsAllInfoById")
    @ApiOperation(value = "根据id获得商品所有的信息", notes = "商品id")
    public Result getGoodsAllInfoById(@RequestBody Map map) {
        return goodsFeignClient.getGoodsAllInfoById(map);
    }

    @PostMapping("/updateGoodsAllInfoById")
    @ApiOperation(value = "根据id修改商品所有的信息", notes = "商品基本信息，商品属性，商品规格，商品货品")
    public Result updateGoodsAllInfoById(@RequestBody Map map) {
        return goodsFeignClient.updateGoodsAllInfoById(map);
    }

    @PostMapping("/deleteGoodsById")
    @ApiOperation(value = "根据id删除商品所有的信息", notes = "商品id")
    public Result deleteGoodsById(@RequestBody Map map) {
        return goodsFeignClient.deleteGoodsById(map);
    }

    @PostMapping("/goodsInOrder")
    @ApiOperation(value = "根据id删除商品所有的信息", notes = "商品id")
    public Result goodsInOrder(@RequestBody Integer goodsId) {
        return goodsFeignClient.goodsInOrder(goodsId);
    }

    @PostMapping("/groupOnShow")
    @ApiOperation(value = "根据商品id展示当前的团购", notes = "商品id")
    public Result groupOnShow(@RequestBody DtsGoods goods){
        return goodsFeignClient.groupOnShow(goods);
    }


}
